MkDiagram
Class representing a mermaid diagram.¶
Description
MkDiagrams can show directed acyclic graphs and allows to manually create diagrams.
Bases: MkCode
__init__
¶
__init__(
names: list[str] | None = None,
connections: list[tuple] | None = None,
*,
direction: Literal["TD", "DT", "LR", "RL"] = "TD",
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
list[str] | None
|
names which should be part of the diagram |
None
|
connections
|
list[tuple] | None
|
tuples indicating the connections of the names |
None
|
direction
|
Literal['TD', 'DT', 'LR', 'RL']
|
diagram direction |
'TD'
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
Name | Children | Inherits |
---|---|---|
MkClassDiagram mknodes.templatenodes.mkclassdiagram Node to display the class hierarchy of a class. Supports multiple modes. |
||
MkPipDepTree mknodes.templatenodes.mkpipdeptree Node to display a mermaid diagram for the dependencies. |
Name | Children | Inherits |
---|---|---|
MkCode mknodes.basenodes.mkcode Class representing a Code block. |
graph TD
94721311944192["mkdiagram.MkDiagram"]
94721306031680["mkcode.MkCode"]
94721311697232["mkcontainer.MkContainer"]
94721308848336["mknode.MkNode"]
94721311766592["node.Node"]
140564252373184["builtins.object"]
94721306031680 --> 94721311944192
94721311697232 --> 94721306031680
94721308848336 --> 94721311697232
94721311766592 --> 94721308848336
140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mkdiagram/metadata.toml
[metadata]
icon = "mdi:graph-outline"
name = "MkDiagram"
group = "diagram"
[[requirements.extension."pymdownx.superfences".custom_fences]]
name = "mermaid"
class = "mermaid"
format = "pymdownx.superfences.fence_code_format"
[examples.regular]
title = "Regular"
jinja = """
{{ ["1", "2", "3"] | MkDiagram(connections=[("1", "2"), ("2", "3")]) }}
"""
[examples.direction]
title = "Direction"
jinja = """
{{ ["1", "2", "3"] | MkDiagram(connections=[("1", "2"), ("2", "3", "comment")], direction="LR") }}
"""
[output.markdown]
template = """
{{ node.fence_boundary }} mermaid
graph {{ node.direction }}
{% if node.connections %}
{% for name in node.names %}
{{ name }}
{% endfor %}
{% for connection in node.connections %}
{% if connection | length == 2 %}
{{ connection[0] }} --> {{ connection[1] }}
{% else %}
{{ connection[0] }} --> |{{ connection[2] }}| {{ connection[1] }}
{% endif %}
{% endfor %}
{% else %}
{% for name in node.names %}
{{ name | get_hash }}["{{ name }}"]
{% endfor %}
{% for prev, nxt in node.names | pairwise %}
{{ prev | get_hash }} --> {{ nxt | get_hash }}
{% endfor %}
{% endif %}
{{ node.fence_boundary }}
"""